#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char*argv[]) {
  /* 
  */
  if (argc!=6) {
    printf("I need 5 arguments! (Np1, outdir, snapbase, nproc, Lbox)\n");
    return;
  }
  else {
    int Np1, nproc, Lbox;
    char fname[100];
    char snapfile[200];
    FILE* fp;
    
    Np1 = atoi(argv[1]);
    nproc = atoi(argv[4]);
    Lbox = atoi(argv[5]);
        
    sprintf(fname, "ahf%d.input",Np1);
    fp = fopen(fname, "w");
    
    fprintf(fp, "[AHF]\n");
    fprintf(fp, "ic_filename = %s\n", argv[3]);
    fprintf(fp, "ic_filetype = 61\n");
    fprintf(fp, "outfile_prefix = %s/halos\n", argv[2]);
    fprintf(fp, "LgridDomain = 128\n");
    fprintf(fp, "LgridMax = 16777216\n");
    fprintf(fp, "NperDomCell = 5.0\n");
    fprintf(fp, "NperRefCell = 5.0\n");
    fprintf(fp, "VescTune = 1.5\n");
    fprintf(fp, "NminPerHalo = 20\n");
    fprintf(fp, "RhoVir = 0\n");
    fprintf(fp, "Dvir = 300\n");
    fprintf(fp, "MaxGatherRad = 6.0\n");
    fprintf(fp, "LevelDomainDecomp = %d\n",(int)(log10(Lbox/15)/0.30103));
    fprintf(fp, "NcpuReading = %d\n", nproc);
    fprintf(fp, "[GADGET]\n");
    fprintf(fp, "GADGET_LUNIT = 1\n");
    fprintf(fp, "GADGET_MUNIT = 1e10\n");
  }
}
